<%@page import="library.dto.MemberDTO"%>
<%@ page language="java" contentType="text/html; charset=UTF-8"
    pageEncoding="UTF-8"%>
    <%@ taglib prefix="c" uri="http://java.sun.com/jsp/jstl/core" %>
    <%@ taglib prefix="fn" uri="http://java.sun.com/jsp/jstl/functions" %>
<!DOCTYPE html PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN" "http://www.w3.org/TR/html4/loose.dtd">
<html>
<head><meta http-equiv="Content-Type" content="text/html; charset=UTF-8">
<script type="text/javascript"  src="/${initParam.context_root }/jquery-1.7.2.min.js"></script>
<script type="text/javascript">

function getZipcode(){
	window.open("res/member/member_register_checkPost.jsp","searchaddress","width=500, height=500, resizable=no, scrollbars=yes");
	//1 : url    2: 팝업화면에 이름
}
function checkInput(){
	var form = document.registerForm;

//비밀번호 check
	if(form.password.value<5){
		alert("비밀번호를 5글자 이상 입력하세요");
		form.password.focus();
		return false;
	}

	if(isNaN(form.hp2.value)||isNaN(form.hp3.value)||form.hp1.value=="default" || form.hp2.value <= 2 ||form.hp3.value <=3){
		alert("휴대전화번호를 올바르게 입력해주세요");
		return false;
	}
	
	if(!form.zipcode.value || !form.address1.value){
		alert("주소를 입력해주세요");
		return false;
	}
	//사진파일체크
	var fileName = form.picture.value;
	var ext = fileNamesubstring(fileName.lastIndexOf(".")+1);
	if(ext!="jpg"&&ext!="png"&&ext!="jpeg"&&ext!="bmp"&&ext!="gif"){
		alert("그림파일만 업로드 가능합니다.");
		return false;
	}else if(!fileName){
		alert("사진을 등록해주세요");
		return false;
	}
}
function resetTxt(txt){
	txt.value="";
}
</script>
</head>
		<%
				MemberDTO mto = (MemberDTO)session.getAttribute("login_info");  
			    String hp = mto.getHp();
		%>
<body>
<form name="registerForm" method="post" action="/${initParam.context_root }/modifyMember.do" enctype="multipart/form-data" onSubmit="return checkInput();">
<input type="hidden" name="id" value="<%=mto.getId()%>">
	<table border="1">
		<tr>
		
			<td width="114" bgcolor="#FF9473">* 회원ID</td>
		  	<td width="412"><input type="text" value="<%=mto.getId()%>" size="20" disabled></td> 
	  </tr>
		<tr>
			<td bgcolor="#FF9473">* 비밀번호</td>
			<td><input type="password" name="password" size="20" maxlength="18" value="<%=mto.getPassword()%>"></td>
		</tr>
		<tr>
			<td  bgcolor="#FF9473">* 이름</td>
			<td><input type="text" value="<%=mto.getName() %>" size="20" disabled></td>
		</tr>
		<tr>
			<td bgcolor="#FF9473">* 주민등록번호</td>
			<td><input type="text" value="<%=mto.getRegisterNumber1() %>" size="6" disabled> - <input type="password" value="<%=mto.getRegisterNumber2() %>" size="7" disabled></td>
		</tr>
		<tr>
			<td  bgcolor="#FF9473">* 휴대전화번호</td>
			<td>
	
			<input type="text" id="hp1" name="hp1" size="3" maxlength="3" value=" <%=hp.substring(0,3) %>">
			<% if(hp.length() >10){ %>
						- <input type="text" name="hp2" size="4" maxlength="4" value="<%=hp.substring(3,7) %>"> - 
						<input type="text" name="hp3" size="4"  maxlength="4" value="<%=hp.substring(7,11) %>">
			<%} else{%>
						- <input type="text" name="hp2" size="4" maxlength="4" value="<%=hp.substring(3,6) %>"> - 
						<input type="text" name="hp3" size="4"  maxlength="4" value="<%=hp.substring(6,10) %>">
			<%} %>
				</td>
		</tr>
		<tr>
			<td  bgcolor="#FF9473">&nbsp;&nbsp;&nbsp;&nbsp;이메일</td>
			<td><input type="text" name="email" value="<%=mto.getEmail()%>"></td>
		</tr>
		  <tr>
			    <td rowspan="3"  bgcolor="#FF9473">* 주소</td>
			    <td><input type="text" size="8" name="zipcode" value="<%=mto.getZipcode()%>"/>
							<input type="button" value="우편번호찾기" onclick="getZipcode()"></td>
		 </tr>
		 <tr> 
			    <td><input type="text" name="address1" value="<%=mto.getAddress1()%>" size="30"></td>
		 </tr>
		 <tr>
			    <td><input type="text" name="address2" value="<%=mto.getAddress2()%>" size="30"></td>
		</tr>
		<tr>
			<td  background="#FF9473">* 사진파일</td>
			<td>			
	           		<input type="file" name="upfile" id="upfile" value="<%=mto.getPictureFilename() %>">
	           		<span id="resultLayer"></span>
 			</td>
		</tr>
		<tr align="center">
			<td height="27" colspan="2" ><input type="submit" value="수정">
											  <input type="reset" value="다시작성">			</td>
		</tr>
	</table>
    <p>&nbsp;</p>
    <p>&nbsp;</p>
    <p>&nbsp;</p>
</form>
</body>
</html>
